<template>
	<view class="page">
    <view class="tips-box">发票开票金额以完成订单后实际产生的金额为准</view>
    <view class="container">
        <view class="list">
          <view class="item">
              <view class="child-item">提交时间：{{ orderDetail.add_time }}</view>
              <view class="child-item">开票金额：{{$t(`￥`)}}{{ orderDetail.price_month }}</view>
              <view class="child-item">发票类型：{{ orderDetail.header_type === 1 ? $t(`个人`) : $t(`企业`) }}</view>
              <!-- <view class="child-item">发票类型：{{ orderDetail.header_type === 1 ? $t(`个人`) : $t(`企业`) }}{{ orderDetail.type === 1 ? $t(`普通`) : $t(`专用`) }}{{$t(`发票`)}}</view> -->
          </view>
        </view>
    </view>
	</view>
</template>

<script>
  import {
  	orderInvoiceList,
    orderInvoiceDetail
  } from '@/api/order.js'
  
	export default {
      data() {
        return {
          date: '',
          invoiceList: [],
          nav: 1, // 1：发票记录 2：抬头管理
          page: 1,
          limit: 30,
          loading: false,
          finished: false,
          order_id: '',
          orderDetail: {}
        }
      },
      onLoad(options){
        console.log('onLoad')
        if(options.detail){
          this.orderDetail = JSON.parse(decodeURIComponent(options.detail))
          console.log('this.orderDetail', this.orderDetail)
          // this.getDetail()
        }
      },
      onShow(){
         console.log('onShow')
         // this.getDetail()
      },
      methods: {
              goPage(item){
                  if(item.path){
                    uni.navigateTo({
                      url: item.path
                    })
                  }
              },
              getInit(){
                this.loading = false;
                this.invoiceList = []
                this.getInvoiceList()
              },
              /**
               * 获取订单详细信息
               * 
               */
              getDetail: function() {
              	let that = this;
              	uni.showLoading({
              		title: that.$t(`正在加载中`)
              	});
              	orderInvoiceDetail(this.order_id).then(res => {
              		console.log('res', res)
                  that.orderDetail = res.data;
              	}).catch(err => {
              		uni.hideLoading();
              		that.$util.Tips({
              			title: err
              		});
              	});
              },
              // 发票列表
              getInvoiceList() {
              	uni.showLoading({
              		title: this.$t(`加载中`)
              	});
              	orderInvoiceList({
              		page: this.page,
              		limit: this.limit,
                  is_invoice: 1 // is_invoice  0未开票 1已开票
              	}).then(res => {
              		const {
              			data
              		} = res;
              		uni.hideLoading();
              		this.invoiceList = this.invoiceList.concat(data);
              		this.finished = data.length < this.limit;
              		this.page += 1;
              	}).catch(err => {
              		uni.showToast({
              			title: err.msg,
              			icon: 'none'
              		});
              	});
              },
      }
	}
</script>

<style lang="scss" scoped>
	page {
    min-height: 100vh;
		background-color: rgb(248,249,252);
	}
  .no-tenant-box{
    .no-tenant-img{
      width: 360rpx;
      height: 360rpx;
      display: block;
      margin: 200rpx auto 10rpx;
    }
    .text{
      text-align: center;
      font-size: 26rpx;
      color: #B9B9BD;
    }
  }
  .tips-box{
    padding: 18rpx 20rpx;
    font-weight: 400;
    font-size: 24rpx;
    color: #008DFF;
    background: #F2F3FF;
  }
	.container {
		margin: 32rpx;
	}
  .list{
    
  }
  .item{
    // display: flex;
    // justify-content: space-between;
    // align-items: center;
    background: #FFF;
    font-size: 28rpx;
    color: rgba(0,0,0,0.9);
    padding: 32rpx 28rpx;
    border-radius: 10rpx;
    margin-bottom: 24rpx;
    .child-item{
      font-size: 28rpx;
      color: rgba(0,0,0,0.9);
      line-height: 60rpx;
    }
  }
</style>
